package com.koal.controller;

import com.koal.pojo.AdminLoginParam;
import com.koal.pojo.ResultBean;
import com.koal.service.IAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "LoginController")
@RestController
public class LoginController {

    @Autowired
    public IAdminService adminService;

    @ApiOperation(value = "登录接口返回Token")
    @PostMapping("/login")
    public ResultBean login(@RequestBody AdminLoginParam adminLoginParam, HttpServletRequest request) {
        return adminService.login(adminLoginParam.getUsername(),adminLoginParam.getPassword(),request);
    }


    @ApiOperation("退出登录")
    @PostMapping("/logout")
    public ResultBean logout() {
        return ResultBean.success("注销成功");
    }
}
